Update the Livewire Component Class:
protected $rules = [
'name' => 'required|min:6',
'email' => 'required|email'
];
public function submitForm()
{
$this->validate();
// Handle form submission, e.g., save to database.
session()->flash('success', 'Form submitted successfully.');
}
In Livewire view file
<form wire:submit.prevent="submitForm">
<input type="text" wire:model="name" placeholder="Name">
@error('name') <span>{{ $message }}</span> @enderror
<input type="email" wire:model="email" placeholder="Email">
@error('email') <span>{{ $message }}</span> @enderror
<button type="submit">Submit</button>
</form>
You Might Also Like
Dynamically Updating Data in Blade Templates
Update data in Blade templates using Livewire components without refreshing the page. This can be be...
Merging Collections of Eloquent Models
<p>This code snippet is useful when you need to merge results from multiple model queries into a si...